package com.tenglong.teacher.ui.adapter;

import android.support.annotation.NonNull;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.ViewGroup;

import com.tenglong.teacher.R;
import com.tenglong.teacher.data.resultInfo.HomeworkErrerTypeInfo;
import com.tenglong.teacher.ui.adapter.viewholder.HomeworkErrerDialogViewHolder;
import com.tenglong.teacher.ui.adapter.viewholder.base.BaseViewHolder;

import java.util.List;

/**
 * @author hdx on 2019/3/21.
 */
public class HomeworkErrerDialogAdapter extends RecyclerView.Adapter<BaseViewHolder<HomeworkErrerTypeInfo>> {
    private List<HomeworkErrerTypeInfo> infos;
    private HomeworkErrerDialogListener listener;

    public HomeworkErrerDialogAdapter(List<HomeworkErrerTypeInfo> infos) {
        this.infos = infos;
    }

    @NonNull
    @Override
    public BaseViewHolder<HomeworkErrerTypeInfo> onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
        return new HomeworkErrerDialogViewHolder(LayoutInflater.from(parent.getContext()).inflate(R.layout.item_homework_errer_dialog, parent, false), listener);
    }

    @Override
    public void onBindViewHolder(@NonNull BaseViewHolder<HomeworkErrerTypeInfo> holder, int position) {
        holder.setLayoutInfo(infos.get(position));
    }

    @Override
    public int getItemCount() {
        return infos.size();
    }

    public void setHomeworkErrerDialogListener(HomeworkErrerDialogListener listener) {
        this.listener = listener;
    }

    public interface HomeworkErrerDialogListener {
        void onHomeworkErrerDialogClick(int position);
    }
}
